#include "Port.h"

Port::Port(const char* br, const char* st, int b)
{
	this->brand = new char[strlen(br) + 1];
	strcpy(this->brand, br);
	strcpy(this->style, st);
	this->bottles = b;
}
Port::Port(const Port& p)
{
	this->brand = new char[strlen(p.brand) + 1];
	strcpy(this->brand, p.brand);
	strcpy(this->style, p.style);
	this->bottles = p.bottles;
}

Port& Port::operator=(const Port& p)
{
	if (this == &p)return *this;
	delete[]this->brand;
	this->brand = new char[strlen(p.brand) + 1];
	strcpy(this->brand, p.brand);
	strcpy(this->style, p.style);
	this->bottles = p.bottles;
	return *this;
}
Port& Port::operator+=(int b)
{
	this->bottles += b;
	return *this;
}
Port& Port::operator-=(int b)
{
	this->bottles -= b;
	return *this;
}
void Port::Show()const
{
	cout << "Brand:" << this->brand << endl;
	cout << "Style:" << this->style << endl;
	cout << "bottles:" << this->bottles << endl;
}
ostream& operator<<(ostream& os, const Port& p)
{
	os << p.brand << " ," << p.style << " ," << p.bottles;
	return os;
}


VintagePort::VintagePort():Port()
{
	this->nickname = new char[1];
	this->nickname[0] = '\0';
	this->year = 0;
}
VintagePort::VintagePort(const char* br, const char* st, const char* nn, int b,int y):Port(br,st,b)
{
	this->nickname = new char[strlen(nn) + 1];
	strcpy(this->nickname, nn);
	this->year = y;
}
VintagePort::VintagePort(const VintagePort& vp):Port(vp)
{
	this->nickname = new char[strlen(vp.nickname) + 1];
	strcpy(this->nickname, vp.nickname);
}

VintagePort& VintagePort::operator=(const VintagePort& vp)
{
	if (this == &vp)return *this;
	delete[] this->nickname;
	Port::operator=(vp);
	this->nickname = new char[strlen(vp.nickname) + 1];
	strcpy(this->nickname, vp.nickname);
	return *this;
}
void VintagePort::Show()const 
{
	Port::Show();
	cout << "nickname:" << this->nickname << endl;
}
ostream& operator<<(ostream& os, const VintagePort& vp)
{
	os << (Port&)vp << " ," << vp.nickname;
	return os;
}